home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / nihcl-30.lha / nihcl-3.0 / ex / Partial.h < prev    next >
C/C++ Source or Header  |  1990-05-15  |  1KB  |  49 lines

  1. #ifndef PartialH
  2. #define PartialH
  3.  
  4. // Partial.h -- partial derivative vector
  5.  
  6. // $Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/ex/RCS/Partial.h,v 3.0 90/05/15 22:43:55 kgorlen Rel $
  7.  
  8. #include <math.h>
  9.  
  10. class ostream;
  11.  
  12. // MAX_ORD is the maximum number of Partial derivatives
  13. // It is possible to make this choice at run-time but
  14. // doing it this way improves speed of computation
  15. #define MAX_ORD 64
  16.  
  17. class Partial {
  18. private:
  19.     int ord; // current order
  20.     double du[MAX_ORD+1];    // array of Partial derivative values
  21. public:
  22.     Partial();
  23.     Partial(double val,int neword =0);
  24.     Partial(const Partial&);
  25.  
  26.     int order() const { return ord; }
  27.     int order(int neword);
  28.  
  29.     void operator=(const Partial&);
  30.     void operator=(double val) { du[0] = val;}
  31.     double& operator[](int i) const { return du[i]; }
  32.     Partial operator-() const;
  33.     Partial pow(int) const;
  34.  
  35.     friend Partial operator+(const Partial&,const Partial&);
  36.     friend Partial operator-(const Partial&,const Partial&);
  37.     friend Partial operator*(const Partial&,const Partial&);
  38.     friend Partial operator/(const Partial&,const Partial&);
  39.  
  40.     friend Partial exp(const Partial& x);
  41.     friend Partial log(const Partial& x);
  42.     friend Partial sin(const Partial& x);
  43.     friend Partial cos(const Partial& x);
  44.     void printOn(ostream&) const;
  45. };
  46.  
  47. extern ostream& operator<<(ostream&,const Partial&);
  48. #endif/* PartialH*/
  49.